﻿using FluentNHibernate.Mapping;
using JaxaraRnD.Models.Objects;

namespace JaxaraRnD.Models.Mapping
{


    public class StaffMap : ClassMap<Staff>
    {
        public StaffMap()
        {
            Id(d => d.Id).GeneratedBy.Native();
            Map(d => d.Name).Length(50);
            Map(d => d.Department).Length(50);
            HasMany(d => d.Orders);
        }
    }

    public class ProductMap : ClassMap<Product>
    {
        public ProductMap()
        {
            Id(d => d.Id).GeneratedBy.Native();
            Map(d => d.Name).Length(50);
            Map(d => d.Category).Length(50);
            HasManyToMany(x => x.Orders).Cascade.All().Table("OrderProduct");
        }
    }

    public class OrderMap : ClassMap<Order>
    {
        public OrderMap()
        {
            Id(d => d.Id).GeneratedBy.Native();
            Map(d => d.IssueDate);
            References(d => d.Staff);
            HasManyToMany(x => x.Products).Cascade.All().Table("OrderProduct");
        }
    }



}